package vn.edu.ptithcm.pim.validator;

import vn.edu.ptithcm.pim.dom.User;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

public class UserValidator implements Validator {

	public boolean supports(@SuppressWarnings("rawtypes") Class clazz) {
		return User.class.isAssignableFrom(clazz);
	}

	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "loginname",
				"signin.warning.missing.loginname");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password",
				"signin.warning.missing.password");
	}
}
